# schemas/recording.py
from typing import Union
from datetime import datetime
from pydantic import Field
from fastapi import Query

from admin.schemas.base import CamelModel


class MeetingsRecordingListIn(CamelModel):
    meeting_id: Union[int, None] = Field(default=None)

    class Config:
        from_attributes = True
        field_operator_mapping = {
            "meeting_id": "=",
        }


class MeetingsRecordingDetailIn(CamelModel):
    id: int = Query(..., gt=0)


class MeetingsRecordingAddIn(CamelModel):
    # note: upload via file in route; this schema used for metadata-only creation
    meeting_id: int = Field(..., gt=0)
    filename: Union[str, None] = None
    mime_type: Union[str, None] = None
    duration_ms: Union[int, None] = None


class MeetingsRecordingEditIn(MeetingsRecordingAddIn):
    id: int = Field(..., gt=0)


class MeetingsRecordingDelIn(CamelModel):
    id: int = Field(..., gt=0)


class MeetingsRecordingOut(CamelModel):
    id: int
    meeting_id: int
    filename: Union[str, None]
    url: Union[str, None]
    processing_status: Union[str, None]
    uploaded_at: Union[datetime, None]

    class Config:
        from_attributes = True
